#include "allhead.h"
#define OK 1

int getline (FILE *f,LPSTR str, int n)
 {
 int i,err;
 char c;

 if(f == NULL) return 0;

 if(feof(f)) return 0;

 for(i=0;i<n-1;i)
   {
   err=fscanf(f,"%c",&c);

   if(((char)err == (char)EOF) && (i==0))
     {
     str[i] = 0;
     return -3;
     }

   if(((char)err != (char)EOF) && ((char)c == (char)'\n') && (i==0)) continue;

   if((char)err == (char)EOF || (char)c == (char)'\n')
     {
     str[i] = 0;
     return 1;
     }
   str[i++] = c;
   }

 return -2;
 }

int skipline (FILE *f)
 {
 int  err;
 char c  ;

 if(f == NULL) return 0;

 if(feof(f)) return 0;

 for(;;)
   {
   err=fscanf(f,"%c",&c);

   if( (char)err == (char)EOF )  return -1;

   if( (char)c   == (char)'\n')  return  1;
   }

 return -1;
 }
